#!/bin/sh
#
# make the keil build output more legible.  the big downside to
# this is that _all_ output is downcased, meaning errors
# involving defined SYMBOLS will look like "symbols" which can be
# confusing.  but in general this makes the output more
# unix-like, and easier to use.
#
# loosely:
#   convert crnl to nl
#   get rid of the compiler banner
#   get rid of the "no errors" line.  silence is golden
#   rearrange the filename, line number, and message to "standard" order
#   downcase everything up to the '|' we just inserted after the filename
#   then get rid of the '|' symbol
#   downcase the ERROR/WARNING words
#   kill the '***', and ' IN '
#   convert back-\ path delimeters to forward-/

tr -d '\r' |
 egrep -v '^$|C51 COMPILER|A51 MACRO ASSEMBLER|COPYRIGHT KEIL' |
  sed -e 's/^.*\<COMPLETE\>.*\<0 WARNING\>.*\<0 ERROR\>.*//' \
    -e 's/\(.*\)LINE \([[:digit:]]\+\) OF \([^:]\+\):\(.*\)/\3:|\2:\1 \4/' \
    -e 's/\(^[^|]*\)/\L\1/g' \
    -e 's/:|/:/' \
    -e 's/\<ERROR\>/\L&/' \
    -e 's/\<WARNING\>/\L&/' \
    -e 's/\*\*\*//' \
    -e 's/ IN /: /' \
    -e 's;\\;/;g'
